import request from '../request';
import {
  GET_APP_CONFIG_REQ,
  REPORT_ARRIVED_PUSH_MSG_REQ,
  GET_FRONT_LOG_STS_TOKEN_REQ,
  GET_FRONT_LOG_OSS_PATH_REQ,
  GET_CLIENT_CONFIG_REQ,
  GET_AUDIO_PRE_UPLOAD_INFO_REQ
} from '../../service/constant';
import { CommonRes } from '../commonRes';
import {
  GetAppConfigParams,
  GetAudioPreUploadInfoParams,
  ReportArrivedPushMsgParams
} from './paramsInterface';
import { GetAppConfigRes } from './getAppConfig';
import { GetFrontLogSTSTokenRes } from './getFrontLogSTSToken';
import { GetFrontLogOSSPathRes } from './getFrontLogOSSPath';
import reportRequest from '../reportRequest';
import { GetClientConfigRes } from './getClientConfig';
import { GetAudioPreUploadInfoRes } from './getAudioPreUploadInfo';

export default {
  // 收到push消息上报
  reportArrivedPushMsg: (
    data: ReportArrivedPushMsgParams
  ): Promise<CommonRes> =>
    request({
      msgId: REPORT_ARRIVED_PUSH_MSG_REQ,
      data
    }),
  // 获取应用配置信息
  getAppConfig: (data: GetAppConfigParams): Promise<GetAppConfigRes> =>
    request({
      msgId: GET_APP_CONFIG_REQ,
      data
    }),
  // 日志上传
  report: (data: string): Promise<any> =>
    reportRequest({
      url: '/v1/log/logger',
      data
    }),
  // 获取上传日志授权
  getFrontLogSTSToken: (): Promise<GetFrontLogSTSTokenRes> =>
    request({
      msgId: GET_FRONT_LOG_STS_TOKEN_REQ
    }),
  // 获取上传日志授权
  getFrontLogOSSPath: (): Promise<GetFrontLogOSSPathRes> =>
    request({
      msgId: GET_FRONT_LOG_OSS_PATH_REQ
    }),
  // 获取客户端配置
  getClientConfig: (): Promise<GetClientConfigRes> =>
    request({
      msgId: GET_CLIENT_CONFIG_REQ
    }),
  // 获取音频预上传信息
  getAudioPreUploadInfo: (
    data: GetAudioPreUploadInfoParams
  ): Promise<GetAudioPreUploadInfoRes> =>
    request({
      msgId: GET_AUDIO_PRE_UPLOAD_INFO_REQ,
      data
    })
};
